<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="../commons/commons.jsp"%>
<!DOCTYPE html>

<head>
    <meta charset="utf-8" />
    <title>Data Tables</title>
</head>
<body>
<div class="page-body">
    <div class="row">
        <div class="col-xs-12 col-md-12">
            <div class="widget">
                <div class="widget-header ">
                    <span class="widget-caption">
        				新增首页轮播图片
                    </span>
                </div>
                <div class="widget-body">
                    <form id="saveOrUpdate" class="form-horizontal form-bordered" role="form" enctype="multipart/form-data" method="post" action="${ ctx}/carousel/save.do">
                    	<div class="form-group">
	                        <label for="inputEmail3" class="col-sm-2 control-label no-padding-right">背景图片</label>
	                        <div class="col-sm-10">
	                        	<input id="backfile" type="file" name="backfile" required="required" class="file nannyuser" data-show-upload="false"/>
	                        </div>
                        </div>
                        <div class="form-group">
	                        <label for="inputEmail3" class="col-sm-2 control-label no-padding-right">人物图片</label>
	                        <div class="col-sm-10">
	                        	<input id="personfile" type="file" name="personfile" required="required" class="file nannyuser" data-show-upload="false"/>
	                        </div>
                        </div>
                        <div class="form-group">
	                        <label for="inputEmail3" class="col-sm-2 control-label no-padding-right">文字描述</label>
	                        <div class="col-sm-10">
	                        	<input type="text" class="form-control" id="describe" name="imgDescribe" 
	                        				placeholder="请输入文字描述" data-bv-notempty="true" data-bv-notempty-message="文字描述不能为空" />
	                        </div>
                       	</div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <a class="btn btn-palegreen" href="javascript:save()">提交</a>
                                <a class="btn btn-palegreen" href="${ctx}/carousel/list.do">返回</a>
                            </div>
                     	</div>
                 	</form>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
	$(document).ready(function () {
	    $('#picUpload').bootstrapValidator();
	});

	var save =function(){
		
		if(!$.trim($('#backfile').val())){
			warningAlert("请上传背景图片");
			return;
		}
		if(!$.trim($('#personfile').val())){
			warningAlert("请上传人物图片");
			return;
		}
		if(!$.trim($('#describe').val())){
			warningAlert("请输入文字描述");
			return;
		}
		$(".page-body").block({
                message: "<img src='${ctx}/img/loading.gif' style='width:25px;height:25px'></img><h4>处理中,请稍后...</h4>",
            });
		$("#saveOrUpdate").ajaxSubmit(function(result) {
			  if(result.status == 1){
			  	 infoAlert("添加成功");
				 window.location.href = "${ctx}/carousel/list.do";
			  }else{
				  warningAlert(result.message[0].msg);
				  $(".page-body").unblock();
			  }
		});
	}

</script>
</html>
